--- plan_query2.sql
set echo on

--- Generate the execution plan.
--- (The query name Q2 is optional)
explain plan for
 select c.customer_id, o.ord_count
 from (select /*+ result_cache q_name(Q2) */
      customer_id, count(*) ord_count
      from orders
      group by customer_id) o, customers c
 where o.customer_id = c.customer_id;

set echo off

--- Display the execution plan.
--- using the code in ORACLE_HOME/rdbms/admin/utlxpls

set markup html preformat on

select plan_table_output from table(dbms_xplan.display('plan_table', null,'serial'));
